using System.Configuration;
using System.Data;
using MySql.Data.MySqlClient;

namespace DataSync.DataAccess.Department
{
    public class DepartmentDataAccess
    {
        private MySqlConnection _MySqlConnection;
        private MySqlCommand _MySqlCommand;
        private MySqlDataAdapter _MySqlDataAdapter;        
        private string _ConnectionString;
        private string _QueryString;

        public DataTable GetDepartments()
        {
            var dataTable = new DataTable();

            _ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionStringCentral"].ToString();
            _MySqlConnection = new MySqlConnection(_ConnectionString);
            _MySqlConnection.Open();

            _QueryString = "SELECT * FROM department";
            _MySqlCommand = new MySqlCommand(_QueryString, _MySqlConnection);            
            _MySqlDataAdapter = new MySqlDataAdapter(_MySqlCommand);
            _MySqlDataAdapter.Fill(dataTable);
            _MySqlConnection.Close();
            return dataTable;
        }
    }
}